const http = uni.$u.http

const getClassify = () => http.get('/api/classify/get', { params: { projectId: 162 } })

const getClassifyBlogList = (id, offset) => http.get('/api/blog/searchByClassifyId', {
	params: {
		id,
		projectId: 162,
		limit: '6',
		offset
	}
})

const getBlogByKeywords = keyword => http.get('/api/blog/searchByInput', {
	params: {
		keyword,
		projectId: 162
	}
})

const login = data => http.post('/api/user/login', data)

const register = data => http.post('/api/user/register', {
	phone: data.phone,
	name: data.name,
	password: data.password,
	projectId: 162
})

const create = (data, token) => http.post('/api/blog/create', data, { header: { 'x-token': token }, })

const getMyBlog = (data, token) => http.get('/api/blog/getMyBlog', {
	params: {
		limit: data.limit,
		offset: data.offset,
		projectId: 162
	},
	header: { 'x-token': token }
})

const getSearch = (id, token) => http.get('/api/blog/search', {
	params: {
		id,
		projectId: 162
	},
	header: { 'x-token': token }
})

const comment = (data, token) => http.post('/api/comment/create', data, { header: { 'x-token': token } })

const getComment = id => http.get('/api/comment/get', {
	params: {
		id,
		projectId: 162
	},
})

const likeComment = (data, token) => http.post('/api/comment/like', data, { header: { 'x-token': token } })

const getLikeUser = token => http.get('/api/user/getLikeUser', { header: { 'x-token': token } })

const followUser = (data, token) => http.post('/api/user/follow', data, { header: { 'x-token': token } })

const getLikeBlog = token => http.get('/api/user/getLikeBlog', { header: { 'x-token': token } })

const setEdit = (data, token) => http.put('/api/user/edit', data, { header: { 'x-token': token } })

const searchUser = (data, token)=> http.get('/api/user/searchUser', { data, header: { 'x-token': token } })

const likeBlog = (data, token)=> http.post('/api/blog/likeBlog', data, { header: { 'x-token': token } })

export {
	getClassify,
	getClassifyBlogList,
	getBlogByKeywords,
	login,
	register,
	create,
	getMyBlog,
	getSearch,
	comment,
	getComment,
	likeComment,
	getLikeUser,
	followUser,
	getLikeBlog,
	setEdit,
	searchUser,
	likeBlog
}
